package com.itqf.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;

/**
 * @Description:
 * @Company: 千锋互联
 * @Author: 李丽婷
 * @Date: 2020/9/30
 * @Time: 下午3:45
 */
public class MyAdvice {

    /**
     * @param joinPoint  通过反射得到目标类和方法相关的详细
     */

    public  void before(JoinPoint joinPoint){
        System.out.println("前"+joinPoint.getTarget().getClass()+
                "=="+joinPoint.getSignature().getName());
    }

    public  void after(JoinPoint joinPoint){
        System.out.println("后"+joinPoint.getTarget().getClass()+
                "=="+joinPoint.getSignature().getName());
    }

    //method in order to support around advice
    public  void around(ProceedingJoinPoint joinPoint){
        System.out.println("around 前----"+joinPoint.getTarget().getClass()+
                "=="+joinPoint.getSignature().getName());
        Object result = null;
        try {
             result =  joinPoint.proceed(); //调用目标方法
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }

        System.out.println(result);
        System.out.println("around 后----"+joinPoint.getTarget().getClass()+
                "=="+joinPoint.getSignature().getName());
    }


}
